package com.ruoyi.project.system.mapper;

import com.ruoyi.project.system.domain.Appointment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AppointmentMapper {
    // 1. 插入预约记录（新增createTime字段）
    @Insert("INSERT INTO appointment (res_id, name, identity_number, phone_number, department, doctor, res_time, create_time) " +
            "VALUES (#{resId}, #{name}, #{identityNumber}, #{phoneNumber}, #{department}, #{doctor}, #{resTime}, NOW())")
    int save(Appointment appointment);

    // 2. 新增：查询预约号是否已存在
    @Select("SELECT COUNT(1) FROM appointment WHERE res_id = #{resId}")
    int countByResId(@Param("resId") String resId);
}